<?php

namespace app\admin\controller;

use think\Controller;

class Understand extends Controller
{
    //
    public function headimg(){
        if(request()->isAjax()){
            $res = model('understand')->save(input('post.'),['id'=>1]);
            if($res){
                $this->success('更新成功',$_SERVER['HTTP_REFERER']);
            }else{
                $this->error('更新失败');
            }
        }
        $headimg = model('understand')->find(1);
        $viewData = [
            'headimg' => $headimg
        ];
        $this->assign($viewData);
        return view();
    }

    public function introduce(){
        if(request()->isAjax()){
            $res = model('understand')->save(input('post.'),['id'=>2]);
            if($res){
                $this->success('更新成功',$_SERVER['HTTP_REFERER']);
            }else{
                $this->error('更新失败');
            }
        }
        $introduce = model('understand')->find(2);
        $viewData = [
            'introduce' => $introduce
        ];
        $this->assign($viewData);
        return view();
    }

    public function lawyer(){
        if(request()->isAjax()){
            $res = model('understand')->save(input('post.'),['id'=>3]);
            if($res){
                $this->success('更新成功',$_SERVER['HTTP_REFERER']);
            }else{
                $this->error('更新失败');
            }
        }
        $lawyer = model('understand')->find(3);
        $viewData = [
            'lawyer' => $lawyer
        ];
        $this->assign($viewData);
        return view();
    }
}
